package com.doctor.windflower_doctor.pop;

import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.PopupWindow;
import android.widget.Toast;

import com.doctor.windflower_doctor.R;
import com.doctor.windflower_doctor.activity.BaseActivity;
import com.doctor.windflower_doctor.delegate.WindflowerDelegate;
import com.doctor.windflower_doctor.util.StringUtil;

/**
 * <p>
 * 功能 修改备注
 * </p>
 * 
 * <p>
 * Copyright 北京亚普拓信息咨询服务有限公司 2014 All right reserved.
 * </p>
 * 
 * @author 皮勉 时间 2014年11月4日 下午1:56:59
 * @version 1.0 </br> 最后修改人 无
 * 
 */
public class EditRellyNamePop extends BasePopupWindow {
	private EditText edit_name;
	private Button cancle, submit;
	private WindflowerDelegate windflowerDelegate;

	public EditRellyNamePop(BaseActivity act) {

		super(act, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
		// TODO Auto-generated constructor stub

	}

	@Override
	protected void setListener() {
		cancle.setOnClickListener(this);
		submit.setOnClickListener(this);
	}

	@Override
	protected void findViews() {
		edit_name = (EditText) findViewById(R.id.edit_name);
		cancle = (Button) findViewById(R.id.cancle);
		submit = (Button) findViewById(R.id.submit);
	}

	@Override
	protected int getContentViewLayoutId() {

		// TODO Auto-generated method stub
		return R.layout.edit_pop;

	}

	@Override
	protected void initViewDrawableSelectCache() {

		// TODO Auto-generated method stub

	}

	@Override
	protected void onItemClick(View view, PopupWindow pop) {
		switch (view.getId()) {
		case R.id.cancle:
			cancle.setTextColor(mAct.getResources().getColor(R.color.public_blue));
			pop.dismiss();
			break;
		case R.id.submit:
			submit.setTextColor(mAct.getResources().getColor(R.color.public_blue));
			String name = edit_name.getText().toString();
			if (!StringUtil.isEmpty(name)) {
				windflowerDelegate.setName(name);
				pop.dismiss();
			} else {
				Toast.makeText(mAct, "备注名为空", Toast.LENGTH_SHORT).show();
			}
			break;
		}
	}

	public void setWindflowerDelegate(WindflowerDelegate windflowerDelegate) {
		this.windflowerDelegate = windflowerDelegate;
	}
}
